// gewPlane
// Properties :
//    a : coefficient for the plane equation
//    b : ----------------------------------
//    c : ----------------------------------
//    d : ----------------------------------
// Description : 
//    A plane : ax+by+cz+d = 0
function gewPlane(point1,point2,point3)
{
  if(!point1||!point2||!point3)
  {
    this.a = this.b = this.c = this.d = 0;
  }
  else
  {
    var n = gewRegVec3;
    point2.sub(point1,gewRegVec8);
    point3.sub(point1,gewRegVec9);
    gewRegVec8.cross(gewRegVec9,n);
    this.a = n.x;
    this.b = n.y;
    this.c = n.z;
    this.d = - point1.dot(n);
    this.normalize();
  }
}
gewPlane.prototype = {
  normalize : function()
  {
    var a = this.a;
    var b = this.b;
    var c = this.c;
    var mag = Math.sqrt(a*a + b*b + c*c);
    this.a/= mag;
    this.b/= mag;
    this.c/= mag;
    this.d/= mag;
  },
  distanceToPoint:function(pt)
  {
    return (this.a*pt.x + this.b*pt.y + this.c*pt.z + this.d);
  }
}